package com.szl.sbssh.model;


import com.szl.sbssh.model.base.IdEntity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * Author: songzhonglin
 * Date: 2018/4/16
 * Time: 14:24
 * Description:
 **/
@Entity
@Table(name = "sys_user")
public class Tuser extends IdEntity implements java.io.Serializable{
    private static final long serialVersionUID = 1867623281523381449L;

    @Column(name = "loginname")
    private String loginname; // 登录名
    @Column(name = "password")
    private String password; // 密码
    @Column(name = "name")
    private String name; // 姓名
    @Column(name = "sex")
    private String sex; // 性别
    @Column(name = "age")
    private Integer age; // 年龄

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "createdatetime", length = 19)
    private Date createdatetime; // 创建时间

    @Column(name = "usertype")
    private String usertype; // 用户类型
    @Column(name = "isdefault")
    private Integer isdefault; // 是否默认
    @Column(name = "state")
    private Integer state; // 状态
    @Column(name = "phone")
    private String phone;
    private Torganization organization;
    private Set<Trole> roles = new HashSet<Trole>(0);

    public Tuser() {
        super();
    }

    public Tuser(String loginname, String name, String sex, Integer age, String usertype, Integer isdefault, Integer state, String phone) {
        this.loginname = loginname;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.usertype = usertype;
        this.isdefault = isdefault;
        this.state = state;
        this.phone = phone;
    }

    public String getLoginname() {
        return loginname;
    }

    public void setLoginname(String loginname) {
        this.loginname = loginname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getCreatedatetime() {
        return createdatetime;
    }

    public void setCreatedatetime(Date createdatetime) {
        this.createdatetime = createdatetime;
    }

    public String getUsertype() {
        return usertype;
    }

    public void setUsertype(String usertype) {
        this.usertype = usertype;
    }

    public Integer getIsdefault() {
        return isdefault;
    }

    public void setIsdefault(Integer isdefault) {
        this.isdefault = isdefault;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_user_role", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) })
    public Set<Trole> getRoles() {
        return roles;
    }

    public void setRoles(Set<Trole> roles) {
        this.roles = roles;
    }

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "organization_id")
    public Torganization getOrganization() {
        return organization;
    }

    public void setOrganization(Torganization organization) {
        this.organization = organization;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}
